<!--
 * @Author: zhayang
 * @LastEditors: zhayang 1063975710@qq.com
 * @Date: 2024-06-15 23:42:21
 * @LastEditTime: 2024-07-06 23:17:21
 * @Description: 简单表格
-->
<template>
  <el-table
    v-loading="loading"
    :data="tableData"
    empty-text="无数据"
    max-height="100%"
    element-loading-text="正在加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(255, 255, 255, 0.8)"
    height="100%"
    v-bind="$attrs"
  >
    <el-table-column
      v-for="(item, key) in columns"
      :key="key"
      v-bind="item"
    >
      <!-- 仅处理列部分 -->
      <template
        v-if="item.type !== 'selection'"
        #default="scope"
      >
        <div class="table-td">
          <slot
            :name="item.prop || item.label || key"
            v-bind="scope"
          >
            <CTd :text="scope.row[item.prop]" />
          </slot>
        </div>
      </template>
      <template
        v-if="item.type !== 'selection'"
        #header="scope"
      >
        <slot
          :name="(item.prop || item.label || key) + 'header'"
          v-bind="scope"
        >
          <CTh :text="scope.column.label" />
        </slot>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import CTd from './td.vue'
import CTh from './th.vue'

export default {
  components: {
    CTd,
    CTh
  },
  props: {
    columns: {
      type: Array,
      default() {
        return []
      }
    },
    tableData: {
      type: Array,
      default() {
        return []
      }
    },
    loading: Boolean,
    noPagination: Boolean
  },
  data() {
    return {}
  },
  created() {
    //
  },
  methods: {
    //
  }
}
</script>

<style lang="scss" scoped></style>
